<?php

/**
 * Auto Code generation
 * @version $Rev:$
 * @license
 */
class Contact_Model_Admin extends Zend_Db_Table_Abstract
{

    public function __construct($config = array())
    {
        $this->_db = Zend_Db_Table::getDefaultAdapter();
        $this->_table = new System_Table_Contact();
        parent::__construct($config);
    }

	public function selectListMessage(){
		$select = $this->_table->select()
					->from($this->_table,array('ID_CONTACT','EMAIL','TITLE','CONTENT','ISREAD','SENT_DATE'))
					->order(array('ID_CONTACT DESC'));
		$result = $this->_table->fetchAll($select);
		return $result;
	}
	
	public function deleteMessage($id){
		$delete = $this->_table->getAdapter()
			->quoteInto('ID_CONTACT = ?', (int)$id);
		$this->_table->delete($delete);
	}
	public function viewMessage($id){	
		$data = $this->_table->find($id)->current();
		return $data;
	}
	
	public function updateIsread($id){
		$isread = array(
			'ISREAD' => 1
		);
		$update = $this->_table->getAdapter()
					->quoteInto('ID_CONTACT = ?', (int)$id);
		$this->_table->update($isread,$update);
	}
	
}

